﻿using SmartRS.com.vn.smartrs.domain;
using SmartRS.com.vn.smartrs.domain.custom;
using SmartRS.com.vn.smartrs.service;
using SmartRS.com.vn.smartrs.util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SmartRS.com.vn.smartrs.controller
{
    public class BillController
    {
        public static void sumarizeBill(IList<BillReportDataRow> list, ref long billCount, ref long cashSum)
        {
            try
            {
                billCount = 0;
                cashSum = 0;
                foreach(BillReportDataRow obj in list){
                    billCount++;
                    cashSum += obj.cashCharge;
                }
            }
            catch(Exception ex)
            {
                throw new Exception("sumarizeBill happend error", ex);
            }
        }

        public static IList<BillReportDataRow> getBillReportData()
        {
            try
            {
                IList<Bill> listBill = BillService.getInstance().getAll();
                return new BillReportDataRow().copyProperties(listBill);
            }
            catch(Exception ex)
            {
                throw new Exception("getBillReportData happened error", ex);
            }
        }
        public static void getBillDataForGridviewReport(string serial, DateTime start, DateTime end, bool isUseDate)
        {
            try
            {
                IList<Bill> list = BillService.getDataBillBySerialAndDate(serial, start, end, isUseDate);
                Session.billReportDataShow = new BillReportDataRow().copyProperties(list);
            }
            catch(Exception ex)
            {
                throw new Exception("getBillDataForGridviewReport happened error " + ex.Message);
            }
        }
    }
}
